package com.kgc.est.controller;


import com.kgc.est.feignService.SmsLogService;
import com.kgc.est.request.SendMsgReq;
import com.kgc.est.utils.Result;
import io.swagger.annotations.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 短信记录 前端控制器
 * </p>
 *
 * @author szq
 * @since 2021-10-19
 */
@Api(tags = "发送短信接口")
@RestController
@RequestMapping("/api/sms")
public class SmsLogController {

    Logger log = LoggerFactory.getLogger(SmsLogController.class);

    @Autowired
    private SmsLogService smsLogService;

    @ApiOperation(value = "发送短信验证码接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "phone",value = "手机号",required = true,dataType = "String"),
            @ApiImplicitParam(name = "codeType",value = "验证码类型",required = true,dataType = "Integer")
    })
    @PostMapping("/verifyCode")
    public Result verifyCode(String phone,Integer codeType){
        log.info("phone{},  codeType{}",phone,codeType);

        SendMsgReq sendMsgReq = new SendMsgReq(phone, codeType);

        return smsLogService.sendSms(sendMsgReq);
    }
}

